﻿using System;
using System.Collections.Generic;
using System.Text;
using HAVNet.Core;


namespace HAVNet.Intros.AST
{
    class ASTMemberDeclMethodI : ASTMemberDeclI
    {
        ASTTypeParamList            _typeParamList  = null;
        ASTFormalParamList          _formalParamList= null;
        ASTTypeConstraintList       _constraints    = null;

        public ASTType              type            { get; set; }
        public string               ident           { get; set; }
        public ASTTypeParamList     typeParamList   { get { if (null == _typeParamList  ) _typeParamList    = new ASTTypeParamList      (); return _typeParamList;  } }
        public ASTFormalParamList   formalParamList { get { if (null == _formalParamList) _formalParamList  = new ASTFormalParamList    (); return _formalParamList;} }
        public ASTTypeConstraintList constraints    { get { if (null == _constraints    ) _constraints      = new ASTTypeConstraintList (); return _constraints;    } }

        public override string ToString ()
        {
            string sMods = "";
            if (Mods.has(modifiers, Mods.newMod     )) sMods += "new ";
            if (Mods.has(modifiers, Mods.unsafeMod  )) sMods += "unsafe ";

            return
                Lazy.toStringNN (_attrGroups, "", Environment.NewLine) +
                sMods           +
                type.ToString() + " " +
                ident           +
                Lazy.toStringNN (_typeParamList, "") +
                "(" + Lazy.toStringNN(_formalParamList, "").Trim() + ")" +
                Lazy.toStringNN (_constraints, "") +
                ";" + Environment.NewLine;
        }
    }
}
